// Protos for identifying metrics and specifying thresholds.

syntax = "proto3";

package nighthawk.adaptive_load;

import "envoy/config/core/v3/extension.proto";
import "google/protobuf/wrappers.proto";
import "validate/validate.proto";

// Identifies a feedback metric.
message MetricSpec {
  // Name of the metric to evaluate. For the set of built-in metric names, see
  // source/adaptive_load/metrics_plugin_impl.cc. Required.
  string metric_name = 1 [(validate.rules).string.min_len = 1];
  // Name of the MetricsPlugin providing the metric. Optional, default "nighthawk.builtin".
  string metrics_plugin_name = 2;
}

// Specifies how to score a metric against a threshold.
message ThresholdSpec {
  // Selection and configuration of a ScoringFunction that measures proximity
  // to a threshold. 0.0 means the value equals the threshold, positive means
  // the value is within the threshold so the input should ramp up, and
  // negative means the value is outside the threshold so input should ramp
  // down.
  envoy.config.core.v3.TypedExtensionConfig scoring_function = 1
      [(validate.rules).message.required = true];
  // Relative importance of this threshold when adjusting based on multiple
  // metrics. Optional, default 1.0.
  google.protobuf.DoubleValue weight = 2 [(validate.rules).double.gt = 0.0];
}

// Identifies a feedback metric and specifies a threshold for it.
message MetricSpecWithThreshold {
  // Identifies a metric to collect and evaluate. Required.
  MetricSpec metric_spec = 1 [(validate.rules).message.required = true];
  // Specifies a threshold for this metric. Required.
  ThresholdSpec threshold_spec = 2 [(validate.rules).message.required = true];
}
